using NServiceBus;

namespace LifecycleAwareness
{
    public class SendEmailMessageHandler : IMessageHandler<SendEmailRequest>
    {
        private readonly IEmailGateway emailGateway;

        public SendEmailMessageHandler(IEmailGateway emailGateway)
        {
            this.emailGateway = emailGateway;
        }

        public void Handle(SendEmailRequest message)
        {
            emailGateway.SendEmail(message.ToAdress,
                                   message.Subject,
                                   message.Body);
        }
    }
}